<template>
  <div class="fhsq_box">
    <header-comm></header-comm>
    <div class="header_sele" :style="$parent.$parent.collapsed==false?'left: 10%':'left:80px'">
      <div></div>
      <div class="add_qy">
        <a-input placeholder="请输入要查询的关键字" v-model="searval" @change="search" />
      </div>
    </div>
    <div class="bcg">
      <div class="fhsq">
        <a-table :columns="columns" @change="getfhsqList" :dataSource="data" :pagination="true">
          <template slot-scope="text, record, index" slot="expandedRowRender">
            <div class="div">
              <!-- <div class="addchild"><a-button  type="primary" size="small">添加</a-button></div> -->
              <div class="ddxxlist ddxxhead">
                <span class="listspan">型号</span>
                <span class="listspan">品牌</span>
                <span class="listspan">发货地址</span>
                <span class="listspan">联系人</span>
                <span class="listspan">联系电话</span>
                <span class="listspan">申请时间</span>
                <span class="listspan">审核状态</span>
                <span class="listspan">操作</span>
              </div>
              <div class="ddxxlist dxbody" v-for="(item,i) in text.child" :key="i">
                <span class="listspan" :class="'xhval_'+i">{{item.xl}}</span>
                <span class="listspan">{{item.sccjc}}</span>
                <span class="listspan">{{item.address}}</span>
                <span class="listspan">{{item.lxr}}</span>
                <span class="listspan">{{item.phone}}</span>

                <span class="listspan">{{item.dateline}}</span>
                <span class="listspan">
                
                  <a-tag color="#108ee9" v-if="item.examine==0">未审核</a-tag>
                  <a-tag color="#87d068" v-if="item.examine==1">通过</a-tag>
                  <a-tag color="#f50" v-if="item.examine==2">未通过</a-tag>
                </span>

                <span class="listspan">
                  <span class="del" @click="shenghe(item.id_num,1)">审核通过</span>
                  <span class="del" @click="shenghe(item.id_num,2)">审核不通过</span>
                  <a-popconfirm
                    title="确定删除吗?"
                    style="color:#1890ff; cursor: pointer;"
                    @confirm="() =>fhsqdel(item.id_num)"
                  >删除</a-popconfirm>
                </span>
              </div>
            </div>
          </template>
        </a-table>
      </div>
    </div>
  </div>
</template>

<script>
import qs from "qs";
import headerComm from "../header-comm/header.vue";
const columns = [
  {
    title: "型号",
    dataIndex: "xl"
  },
  {
    title: "品牌",
    dataIndex: "sccjc"
  },
  {
    title: "手机号",
    dataIndex: "phone"
  }
];
const data = [];
export default {
  data() {
    return {
      data,
      columns,
      pagination: {
        defaultPageSize: 10,
        showTotal: total => `共 ${total} 条数据`,
        total: 0,
        current: 1
      },
      remark: "",
      shyyval: {
        key: "",
        val: ""
      },
      searval: ""
    };
  },

  methods: {
    getfhsqList(pagination) {
      this.pagination.current = pagination.current;
      this.axios
        .post(
          "fhl/kcds/applyShipList.php",
          qs.stringify({
            page: this.pagination.current,
            pageSize: pagination.defaultPageSize,
            sqdwid: this.$store.state.bbl_sqdwid,
            filed: this.searval
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 303) {
            this.pagination.total = res.data.total;
            for (var i = 0; i < res.data.result.length; i++) {
              res.data.result[i].key = i;
            }
            this.data = res.data.result;
          } else {
            this.data = [];
          }
        });
    },

    search() {
      this.getfhsqList(this.pagination);
    },
    shenghe(id_num, examine_type) {
      this.axios
        .post(
          "fhl/kcds/applyShipExamine.php",
          qs.stringify({
            id_num: id_num,
            examine_type: examine_type
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 303) {
            this.getfhsqList(this.pagination);
            this.$notification["success"]({
              message: "成功",
              description: res.data.msg
            });
          } else {
            this.$notification["error"]({
              message: "失败",
              description: res.data.msg
            });
          }
        });
    },
    fhsqdel(id_num) {
      this.axios
        .post(
          "fhl/kcds/applyShipDelete.php",
          qs.stringify({
            id_num: id_num
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 303) {
            this.getfhsqList(this.pagination);
            this.$notification["success"]({
              message: "成功",
              description: res.data.msg
            });
          } else {
            this.$notification["error"]({
              message: "失败",
              description: res.data.msg
            });
          }
        });
    }
  },
  components: {
    headerComm
  },

  created() {
    this.getfhsqList(this.pagination);
  }
};
</script>

<style lang='less'>
.fhsq_box{
.header_sele {
  position: fixed;
  top: 55px;
  left: 200px;
  z-index: 999;
  text-align: right;
  width: 90%;
  background-color: #fff;
  box-shadow: 5px 5px 5px #ccc;
  // height: 50px;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.fhsq {
  position: relative;
  top: 143px;
  left: 1%;
  background: #fff;
  width: 98%;
  .ddxxlist {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 10px;
    .listspan {
      // display: flex;
      // justify-content: space-between;
      width: 20%;
      .anticon svg {
        font-size: 18px;
      }
    }
    .rightspan {
      width: 10%;
      text-align: right;
    }
    span {
      button {
        margin: 0 10px;
      }
      .button {
        background-color: #1890ff;
        border: 0 !important;
      }
    }
    .orange {
      color: red;
      .input {
        outline: none;
        border: 0;
        border: 1px solid #ccc;
        border-radius: 5px;
        padding: 3px 8px;
      }
    }
    .red {
      font-size: 14px;
    }
  }
}
.shyy_tk {
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.5);
  width: 100%;
  height: 1000px;
  z-index: 999;
  .sryy {
    position: absolute;
    left: 35%;
    top: 10%;
    width: 30%;
    background: #fff;
    height: 246px;
    text-align: center;
    padding: 46px;
    textarea {
      width: 96%;
    }
    .btn {
      margin-top: 20px;
      text-align: center;
    }
  }
}
}

</style>
